From: Florian Müllner Date: Thu, 21 Dec 2023 17:43:17 +0000 (+0100) Subject: main: Override global logError() function X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~281^2~2^2~207 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=dc655b9ed002f89ae1b6cd874bbe68193018f4af;p=gnome-shell.git main: Override global logError() function logError() prints an exception with an optional prefix, and is used fairly commonly through-out the code base. The problem is that by being defined in gjs, it uses "Gjs" as the GLib log domain, not our own as expected. Address this by adding a small override that implements the function with console.error(). Part-of: --- diff --git a/js/ui/main.js b/js/ui/main.js index ad6d3d611..3781c9607 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -143,6 +143,16 @@ function _sessionUpdated() { /** @returns {void} */ export async function start() { globalThis.log = console.log; + globalThis.logError = function (err, msg) { + const args = [err]; + try { + // toString() can throw + if (msg) + args.unshift(`${msg}:`); + } catch (e) {} + + console.error(...args); + }; // Chain up async errors reported from C global.connect('notify-error', (global, msg, detail) => {